<%@ page language="java" pageEncoding="utf-8"%>
<%@page import="com.wframe.framework.util.UploadUtil"%>
<%@taglib uri="/WEB-INF/page-base.tld" prefix="w"%>
<%@ include file="/plugins/plupload2/plupload.jsp"%>
<%String path=request.getContextPath();request.setAttribute("fileserver", UploadUtil.getConfig().getDownserver()); %>
<w:define bind="bean.pid" id="pid"/>
<script>
	function loadclasstreeok(){
		$("#proclassbox").combotree("setValue","<%=pid%>");
	}
</script>
<script>
    var channeluploader;
    function selchannelimg(){

    }
    function delplphoto(fid,bl){
        try{
            var f=channeluploader.getFile(fid);
            channeluploader.removeFile(f);
        }catch(e){}
        $('#plfile_'+fid).remove();
    }

    var saveing=false;
    function savenext(){
        if(!saveing){
            saveing=true;
            if(channeluploader.files.length>0)channeluploader.start();
            else savechannelSubmit();
        }
    }
    function savechannelSubmit(){
        $w.doWinForm(function(re){
                var reobj={"id":re.id,"rootCode":re.rootCode,"pid":$getByName("bean.pid",$w.currWin().val()),"name":$getByName("bean.name",$w.currWin()).val(),"photo":$getByName("bean.photo",$w.currWin()).val(),
					"orderno":$getByName("bean.orderno",$w.currWin()).val()};
        });
    }
</script>
<div class="easyui-panel" data-options="doSize:false,layoutH:47,border:false" style="margin:5px">
	<form method="post" action="/products/ProductClassPage@update.page" class="pageForm">
		<w:hidden bind="bean.id"/>
		<w:hidden bind="rootCode"/>
		<div class="ui-formContent">
			<p>
				<label style="width:130px;text-align:right">上级分类：</label>
				<select name="bean.pid" id="proclassbox"  class="easyui-combotree" style="width:400px;height:30px;" data-options="url:'<%=path %>/products/ProductClassPage@loadClassTree.page?bean.code=<w:write bind="rootCode"/>',onLoadSuccess:loadclasstreeok"></select>
			</p>
			<p>
				<label style="width:130px;text-align:right"><font class="red">*</font>分类名称：</label>
				<w:text bind="bean.name" styleClass="easyui-validatebox" dataOptions="required:true"  style="width:400px"/>
			</p>
			<p>
				<label style="width:130px;text-align:right">排序号：</label>
				<w:text bind="bean.orderno" style="width:400px"/>
			</p>

			<table cellpadding="0" cellspacing="0">
				<tr>
					<td valign="top" style="padding-top:4px;"><label style="width:130px;text-align:right"><font class="red">*</font>栏目图片：</label></td>
					<td valign="top" style="width:200px;padding-top:4px;padding-left:4px;" id="channelimg">
						<w:notEqual bind="bean.photo" value="">
							<w:hidden bind="bean.photo"/>
							<img src="${fileserver }<w:write bind="bean.photo"/>" style="width:200px">
						</w:notEqual>
						<w:equal bind="bean.photo" value="">
							<img src="<%=path %>/images/selimg.png" style="width:200px">
						</w:equal>
					</td>
					<td valign="top" style="padding-top:4px;padding-left:4px;">
						<a href="javascript:void(0);" class="ui_btn" id="channelimgbtn" onclick="selchannelimg()">选择图片</a>
						<!-- <p class="red" style="color:red">建议上传1024*300尺寸图片</p> -->
					</td>
				</tr>
			</table>
		</div>
	</form>
</div>
<div class="ui-buttonBar">
	<a href="javascript:;" class="easyui-linkbutton marginR16" iconCls="icon_save" onclick="savenext()">保 存</a>
	<a href="javascript:;" class="easyui-linkbutton" iconCls="icon_cancel" onclick="$w.closeCurrWin()">取 消</a>
</div>
<script src="<%=request.getContextPath() %>/plugins/oss/upload.js" type="text/javascript"></script>
<script src="<%=request.getContextPath() %>/plugins/plupload2/plupload.dev.js" type="text/javascript"></script>
<script src="<%=request.getContextPath() %>/plugins/plupload2/plupload.full.min.js" type="text/javascript"></script>
<script>
    var plparm={
        runtimes : 'html5,flash,silverlight,html4',
        browse_button : 'channelimgbtn',
        flash_swf_url : ctx+'/plugins/plupload/js/Moxie.swf',
        silverlight_xap_url : ctx+'/plugins/plupload/js/Moxie.xap',
        filters : {
            max_file_size : '2mb',
            mime_types: [
                {title : "Image files", extensions : "jpg,gif,png"}
            ]
        },
        init: {
            FilesAdded: function(up, files) {
                $("#channelimg").html('');
                if(files.length>0){
                  //  if(channeluploader.files.length>1)channeluploader.removeFile(uploaderobj.files[0]);
                }
                filesAdded(up,files,'#channelimg');
            },

            UploadProgress: function(up, file) {
                uploadProgress(up,file);
            },
            FileUploaded:function(up,file,responseObject){
                var re=jQuery.parseJSON(responseObject.response);
                $('#plimgurl_'+file.id).val(re.url.replace(re.basepath,""));
            },
            UploadComplete:function(up,files){
                savechannelSubmit();
            },
            Error: function(up, err) {upError(up, err,'2mb');}
        }
    };
    $oss.setUpDir('info');
    channeluploader=$oss.initUpload(plparm);
</script>